// Copyright(C) 2023 InfiniFlow, Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

export module infinity_core:expression_selector;

import :base_expression;
import :data_block;
import :selection;

namespace infinity {
class ExpressionState;
struct ColumnVector;

export class ExpressionSelector {
public:
    size_t Select(const std::shared_ptr<BaseExpression> &expr,
                  std::shared_ptr<ExpressionState> &state,
                  const DataBlock *input_data_block,
                  DataBlock *output_data_block,
                  size_t count);

    void Select(const std::shared_ptr<BaseExpression> &expr,
                std::shared_ptr<ExpressionState> &state,
                size_t count,
                const std::shared_ptr<Selection> &input_select,
                std::shared_ptr<Selection> &output_true_select,
                std::shared_ptr<Selection> &output_false_select);

    void Select(const std::shared_ptr<BaseExpression> &expr,
                std::shared_ptr<ExpressionState> &state,
                size_t count,
                std::shared_ptr<Selection> &output_true_select);

    static void Select(const std::shared_ptr<ColumnVector> &bool_column, size_t count, std::shared_ptr<Selection> &output_true_select, bool nullable);

private:
    const DataBlock *input_data_{nullptr};
};

} // namespace infinity
